/*
 * Copyright 2014 Davy Maddelein.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.compomics.pepshell.view.dataloading.frames;

import com.compomics.pepshellmslimsconnector.tempholder.MsLimsDbDAO;

/**
 *
 * @author Davy Maddelein
 */
class ModeSelectionFrame extends javax.swing.JFrame {

    /**
     * Creates new form ModeSelectionFrame
     */
    public ModeSelectionFrame() {
        initComponents();
        
        dataSourceSelectionGroup.add(dbSelectionRadioButton);
        dataSourceSelectionGroup.add(fastaSelectionRadioButton);
        
        //select dbSelectionRadioButton
        dbSelectionRadioButton.setSelected(true);
        
        setLocationRelativeTo(null);
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        dataSourceSelectionGroup = new javax.swing.ButtonGroup();
        parentPanel = new javax.swing.JPanel();
        dataCollectionFrameButton = new javax.swing.JButton();
        dbSelectionRadioButton = new javax.swing.JRadioButton();
        fastaSelectionRadioButton = new javax.swing.JRadioButton();
        jLabel1 = new javax.swing.JLabel();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setTitle("data source selection");
        setBackground(new java.awt.Color(255, 255, 255));

        parentPanel.setBackground(new java.awt.Color(255, 255, 255));

        dataCollectionFrameButton.setText("continue...");
        dataCollectionFrameButton.addActionListener(new java.awt.event.ActionListener() {
            @Override
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                dataCollectionFrameButtonActionPerformed(evt);
            }
        });

        dbSelectionRadioButton.setText("database connection");
        dbSelectionRadioButton.setOpaque(false);

        fastaSelectionRadioButton.setText("file based");
        fastaSelectionRadioButton.setOpaque(false);

        jLabel1.setText("Select a data source");

        javax.swing.GroupLayout parentPanelLayout = new javax.swing.GroupLayout(parentPanel);
        parentPanel.setLayout(parentPanelLayout);
        parentPanelLayout.setHorizontalGroup(
            parentPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(parentPanelLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(parentPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addGroup(parentPanelLayout.createSequentialGroup()
                        .addGroup(parentPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(fastaSelectionRadioButton)
                            .addComponent(dbSelectionRadioButton))
                        .addGap(0, 115, Short.MAX_VALUE))
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, parentPanelLayout.createSequentialGroup()
                        .addGap(0, 0, Short.MAX_VALUE)
                        .addComponent(dataCollectionFrameButton)))
                .addContainerGap())
        );
        parentPanelLayout.setVerticalGroup(
            parentPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(parentPanelLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel1)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(dbSelectionRadioButton)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(fastaSelectionRadioButton)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 18, Short.MAX_VALUE)
                .addComponent(dataCollectionFrameButton)
                .addContainerGap())
        );

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(parentPanel, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(parentPanel, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
        );

        pack();
        setLocationRelativeTo(null);
    }// </editor-fold>//GEN-END:initComponents

    private void dataCollectionFrameButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_dataCollectionFrameButtonActionPerformed

        if (dbSelectionRadioButton.isSelected()) {
            this.dispose();
            ExperimentSelectionFrame frame = new ExperimentSelectionFrame(new MsLimsDbDAO());
        } else if (fastaSelectionRadioButton.isSelected()) {
            new FileSelectionFrame().setVisible(true);
            this.dispose();
        }

    }//GEN-LAST:event_dataCollectionFrameButtonActionPerformed
    
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton dataCollectionFrameButton;
    private javax.swing.ButtonGroup dataSourceSelectionGroup;
    private javax.swing.JRadioButton dbSelectionRadioButton;
    private javax.swing.JRadioButton fastaSelectionRadioButton;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JPanel parentPanel;
    // End of variables declaration//GEN-END:variables
}
